package com.xyy.kingdeek3cloud.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.xyy.kingdeek3cloud.entity.pop.ApiRPCResult;
import com.xyy.kingdeek3cloud.service.PopApiService;
import com.xyy.kingdeek3cloud.utils.http.RedirectUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;


@Slf4j
@Service
public class PopApiServiceImpl implements PopApiService {


    @Override
    public ApiRPCResult<Boolean> pushDataInfo(Map<String, Object> var1) {
        String body = RedirectUtil.doPostByJson("https://h-api.ybm100.com/api/hackTask/pushDataInfo", JSON.toJSONString(var1));
        ApiRPCResult<Boolean> apiRPCResult = JSON.parseObject(body, ApiRPCResult.class);
        if (apiRPCResult == null || apiRPCResult.isFail()) {
            log.warn("#数据上报失败 taskQueryParam:{}, apiRPCResult：{}", JSONObject.toJSONString(var1), JSON.toJSONString(apiRPCResult));
            return new ApiRPCResult<>();
        }
        log.info("数据上报成功,JsonData: {}", JSON.toJSONString(var1));
        log.info("接口信息: {}", JSON.toJSONString(apiRPCResult));
        return apiRPCResult;
    }
}
